<?php
class testControl extends skymvc{
	
	public function __construct(){
		parent::__construct();
	}
	
	public function onDefault(){
		$sql="select a.id,a.title,a.imgurl,a.description,b.content 
				from ".table('product')." as a left join ".table('product_data')." as b 
				on a.id=b.id
				where a.status=2 
				
		";
		$data=M("product")->getAll($sql);
		foreach($data as $k=>$v){
			$name=basename($v['imgurl']);
			$v['imgurl']="attach/demo/".$name;
			$data[$k]=$v;
			/*
			copy($v['imgurl'],"test/product/".$name);
			copy($v['imgurl'].".100x100.jpg","test/product/".$name.".100x100.jpg");
			copy($v['imgurl'].".small.jpg","test/product/".$name.".small.jpg");
			copy($v['imgurl'].".middle.jpg","test/product/".$name.".middle.jpg");
			*/
		}
		file_put_contents("test/product/data.txt",json_encode($data));
	}
	 
	
	 
	
}
?>